/*
main.cpp:
    程序测试入口代码
*/
#include <iostream>
#include <string>
#include <stdlib.h>
#include "table.h"
#include "MyThread.h"

int main()
{
    // 测试
    table* threadTable=table::GetTable();
    threadTable->InsertRecord(); // 测插入
    int lowerBound = 0;
    int upperBound = 0;
    int col = 0;
    printf("测试非多线程的查询...\n");
    printf("请输入查询下界: ");
    scanf("%d", &lowerBound);
    printf("请输入查询上界: ");
    scanf("%d", &upperBound);
    printf("请输入查询目标列数: ");
    scanf("%d", &col);
    threadTable->SearchRecord(lowerBound, upperBound, col); // 单测搜索
    printf("测试多线程的查询...\n");
    printf("请输入查询下界: ");
    scanf("%d", &lowerBound);
    printf("请输入查询上界: ");
    scanf("%d", &upperBound);
    printf("请输入查询目标列数: ");
    scanf("%d", &col);
    FunctionInterface* threadSearch=new FunctionSearch(lowerBound, upperBound, col); // 测搜索+多线程
    FunctionInterface* threadInsert = new FunctionInsert(); // 测插入+多线程
    FunctionThreadInterface *pThreadSearch=new FunctionThread(threadSearch);
    pThreadSearch->Run();
    pThreadSearch->WaitForDeath();
    FunctionThreadInterface *pThreadInsert=new FunctionThread(threadInsert);
    pThreadInsert->Run();
    pThreadInsert->WaitForDeath();
}
